﻿using Furion;
using System.Linq;
using System.Text.Json.Serialization;

namespace SEIPropertyDataService.Entity.ViewModels
{
    /// <summary>
    /// 组分viewmodel
    /// </summary>
    public class VM_Component
    {
        private int _pCdataCompID;
        /// <summary>
        /// 组分ID
        /// </summary>
        public int PCdataCompID
        {
            get
            {
                return _pCdataCompID;
            }
            set
            {
                _pCdataCompID = value;
                var request = App.HttpContext.Request;

                // 获取负载均衡器传递的原始信息
                var host = request.Headers["X-Forwarded-Host"].FirstOrDefault()
                         ?? request.Host.Value;

                var scheme = request.Headers["X-Forwarded-Proto"].FirstOrDefault()
                          ?? request.Scheme;

                // 自动补全协议
                if (!host.Contains("://"))
                {
                    host = $"{scheme}://{host}";
                }
                this.Image2D = $"{host}/StaticResource/ComponentsSource/svg/mol_{value}.svg";
                this.Image3D = $"{host}/StaticResource/ComponentsSource/html/mol_{value}.html";
                //this.Image2D = $"{(App.HttpContext.Request.Host.Value.StartsWith("http") ? App.HttpContext.Request.Host.Value : ("http://" + App.HttpContext.Request.Host.Value))}/StaticResource/ComponentsSource/svg/mol_{value}.svg";
                //this.Image3D = $"{(App.HttpContext.Request.Host.Value.StartsWith("http") ? App.HttpContext.Request.Host.Value : ("http://" + App.HttpContext.Request.Host.Value))}/StaticResource/ComponentsSource/html/mol_{value}.html";
            }
        }
        /// <summary>
        /// PCdataCompNo
        /// </summary>
        public string PCdataCompNo { get; set; }
        /// <summary>
        /// 组分名称
        /// </summary>
        public string CompName { get; set; }
        /// <summary>
        /// 组分别名列表
        /// </summary>
        public string CompNameAliasList { get; set; }
        /// <summary>
        /// 组分中文名称
        /// </summary>
        public string CompNameCN { get; set; }
        /// <summary>
        /// IUPAC名称
        /// </summary>
        public string IUPACName { get; set; }
        /// <summary>
        /// 分子式
        /// </summary>
        public string Formula { get; set; }
        /// <summary>
        /// CAS号
        /// </summary>
        public string CASNo { get; set; }
        /// <summary>
        /// SMILES配方
        /// </summary>
        public string SMILES { get; set; }
        /// <summary>
        /// PubChemID
        /// </summary>
        public string PubChemID { get; set; }
        /// <summary>
        /// InChiID
        /// </summary>
        public string InChiID { get; set; }
        /// <summary>
        /// InChiKey
        /// </summary>
        public string InChiKey { get; set; }
        /// <summary>
        /// 分子质量（MW），默认没有值，查看详情时才会有
        /// </summary>
        public double? MW { get; set; }
        ///// <summary>
        ///// 
        ///// </summary>
        //public int DSIID { get; set; }
        ///// <summary>
        ///// 
        ///// </summary>
        //public int DDBID { get; set; }
        ///// <summary>
        ///// 
        ///// </summary>
        //public string DDBEAspen { get; set; }
        ///// <summary>
        ///// 
        ///// </summary>
        //public string AspenID { get; set; }
        ///// <summary>
        ///// 
        ///// </summary>
        //public int TRCID { get; set; }
        ///// <summary>
        ///// 
        ///// </summary>
        //public int DipprID { get; set; }
        /// <summary>
        /// OpenID
        /// </summary>
        public int OpenID { get; set; }
        /// <summary>
        /// 是否可以进行纯组分物性计算
        /// </summary>
        public bool CanCalcPureProperty { get; set; }
        /// <summary>
        /// 2d图片地址
        /// </summary>
        public string Image2D { get; set; }
        /// <summary>
        /// 3d图片地址
        /// </summary>
        public string Image3D { get; set; }
        ///// <summary>
        ///// 建立日期
        ///// </summary>
        //[JsonConverter(typeof(CustomDateTimeConverter))]
        //public DateTime? CreateDate { get; set; }
        ///// <summary>
        ///// 修改日期
        ///// </summary>
        //[JsonConverter(typeof(CustomDateTimeConverter))]
        //public DateTime? UpdateDate { get; set; }
        ///// <summary>
        ///// 描述
        ///// </summary>
        //public string Description { get; set; }

        /// <summary>
        /// 查询匹配度
        /// </summary>
        [JsonIgnore]
        public int MatchSC { get; set; }
    }
}
